import {_decorator, Component, Node, Sprite, SpriteFrame, Label, CCInteger} from 'cc';
import {GameMany2048} from "db://assets/scripts/2048/GameMany2048";

const {ccclass, property} = _decorator;

@ccclass('PropItemScript')
export class PropItemScript extends Component {

    sprite: Sprite = null;

    type: number = null;
    id: string;
    game: GameMany2048;

    titile: string;
    body: string;

    start() {

    }

    update(deltaTime: number) {

    }

    public click() {
        console.log("使用道具", this.type)
        if (this.node.parent.name !== 'MePropContainer') {
            return;
        }
        this.game.useProp(this);
    }

    public touchLone(event) {
        console.log('触摸',event)
        // 长按显示消息
        if (this.node.parent.name !== 'MePropContainer') {
            return;
        }
        this.game.showPropDesc(this);
    }

    public touchLoneCanel() {
        // 长按显示消息
    }

    public init(spriteFramge: SpriteFrame,
                titile: string,
                body: string,
                type: number,
                id: string,
                game: GameMany2048) {
        this.game = game;
        this.sprite = this.node.children[0].getComponent(Sprite);
        this.titile = titile;
        this.body = body;


        this.node.children[0].getComponent(Sprite).spriteFrame = spriteFramge;
        this.type = type;
        this.id = id;

    }
}


